/*
 * Copyright (c) 2015 Messcat. All rights reserved.
 * 
 */
package cc.messcat.common.model;

import java.io.Serializable;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonView;

import cc.messcat.common.model.views.Views;

public class Pager<T> implements Serializable {

	private static final long serialVersionUID = 6550357038191933684L;

	// 默认值不可去除
	@JsonView(Views.class)
	private int pageSize = 10;
	@JsonView(Views.class)
	private int pageNo = 1;
	@JsonView(Views.class)
	private int rowCount;
	@JsonView(Views.class)
	private int pageCount;
	@JsonView(Views.class)
	private int pageSizeList[] = { 5, 10, 30, 50, 100 };
	@JsonView(Views.class)
	private List<T> resultList;

	public Pager() {
		super();
	}

	public Pager(int pageSize, int pageNo, int rowCount, List<T> resultList) {

		super();
		pageCount = 1;
		this.pageSize = pageSize;
		this.pageNo = pageNo;
		this.rowCount = rowCount;
		this.resultList = resultList;
		if (rowCount % pageSize == 0)
			pageCount = rowCount / pageSize;
		else
			pageCount = rowCount / pageSize + 1;

	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int[] getPageSizeList() {
		return pageSizeList;
	}

	public void setPageSizeList(int pageSizeList[]) {
		this.pageSizeList = pageSizeList;
	}

	public List<T> getResultList() {
		return resultList;
	}

	public void setResultList(List<T> resultList) {
		this.resultList = resultList;
	}

	public int getRowCount() {
		return rowCount;
	}

	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
	}

}